package com.function.study;

/**
 * 斐波那契数列
 *
 * @program: study
 * @className: RecursiveFibonacci
 * @description: TODO
 * @author: kukuxiahuni
 * @create: 2019-12-16 10:10
 * @version: v1.0
 **/
public class RecursiveFibonacci {

    private InterCall call;

    public RecursiveFibonacci() {
        call = n -> n == 0 ? 0 :
                n == 1 ? 1 :
                        call.call(n - 1) + call.call(n - 2);
    }

    public static void main(String[] args) {
        RecursiveFibonacci recursiveFibonacci = new RecursiveFibonacci();
        for (int i = 0; i <= 10; i++)
            System.out.println(recursiveFibonacci.fib(i));
    }

    int fib(int n) {
        return this.call.call(n);
    }

}
